package cn.com.nwpu.visual_system.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;

/**
 * @author Hutengzhong
 * @version 1.0.0
 * @title SensorOperateData
 * @description TODO 11个操作传感器
 * @date 2024/4/27 22:51
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SensorOperateData {
    private Integer sensorDataId;
    private LocalDateTime insertTime;
    private Double XMV1;
    private Double XMV2;
    private Double XMV3;
    private Double XMV4;
    private Double XMV5;
    private Double XMV6;
    private Double XMV7;
    private Double XMV8;
    private Double XMV9;
    private Double XMV10;
    private Double XMV11;

    public SensorOperateData(HashMap parameters) {
        if (parameters == null) {
            return;
        } else {
            if (parameters.containsKey("sensorDataId")) {
                sensorDataId = Integer.parseInt((String) parameters.get("sensorDataId"));
            }
            if (parameters.containsKey("insertTime")) {
                insertTime = LocalDateTime.parse((String) parameters.get("birthday"),
                        DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            }
            if (parameters.containsKey("XMV1")) {
                XMV1 = Double.parseDouble((String) parameters.get("XMV1"));
            }
            if (parameters.containsKey("XMV2")) {
                XMV2 = Double.parseDouble((String) parameters.get("XMV2"));
            }
            if (parameters.containsKey("XMV3")) {
                XMV3 = Double.parseDouble((String) parameters.get("XMV3"));
            }
            if (parameters.containsKey("XMV4")) {
                XMV4 = Double.parseDouble((String) parameters.get("XMV4"));
            }
            if (parameters.containsKey("XMV5")) {
                XMV5 = Double.parseDouble((String) parameters.get("XMV5"));
            }
            if (parameters.containsKey("XMV6")) {
                XMV6 = Double.parseDouble((String) parameters.get("XMV6"));
            }
            if (parameters.containsKey("XMV7")) {
                XMV7 = Double.parseDouble((String) parameters.get("XMV7"));
            }
            if (parameters.containsKey("XMV8")) {
                XMV8 = Double.parseDouble((String) parameters.get("XMV8"));
            }
            if (parameters.containsKey("XMV9")) {
                XMV9 = Double.parseDouble((String) parameters.get("XMV9"));
            }
            if (parameters.containsKey("XMV10")) {
                XMV10 = Double.parseDouble((String) parameters.get("XMV10"));
            }
        }
    }
}
